/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ps.server;

import com.ps.server.classes.*;
import java.util.Hashtable;
import java.util.Vector;

/**
 *
 * @author Ricardo
 */
public class BDLocal {

    Object[][] ModelData;
    String[] MetaData;
    Vector data;
    Hashtable dataHashtable;
public BDLocal(String resource,String id_language) {
   ClientRest cr = new ClientRest();
   cr.ejecutarMetodoGet(resource, "?display=full&filter[id_country]=[" + id_language + "]");
    if (resource.equals("tax_rules")) {
            //rs.GetAll(resource);
            //this.setDataConfigurations(rs.dataHas());
            this.setTax_Rules(cr.getconfig());
        }

}
    public BDLocal(String resource) {

        ClientRest cr = new ClientRest();

        cr.ejecutarMetodoGet(resource, "?display=full");
        /*
         * if(resource.equals("configurations")){ datHas= cr.getconfig(); }else{
         * this.FullData = cr.getGetVector(); }
         */
        //operacion rs = new operacion();
        if (resource.equals("languages")) {
            //rs.GetAll(resource);
            //setDataLanguages((Vector<languages>) rs.Data());
            setDataLanguages((Vector<languages>) cr.getVector());
        }

        if (resource.equals("manufacturers")) {
            // rs.GetAll(resource);
            //setDataManufacturers((Vector<manufacturers>) rs.Data());
            setDataManufacturers((Vector<manufacturers>) cr.getVector());
        }

        if (resource.equals("suppliers")) {
            //rs.GetAll(resource);
            //setDataSuppliers((Vector<suppliers>) rs.Data());
            setDataSuppliers((Vector<suppliers>) cr.getVector());
        }
        if (resource.equals("categories")) {
            //rs.GetAll(resource);
            //setDataCategories((Vector<categories>) rs.Data());
            setDataCategories((Vector<categories>) cr.getVector());
        }


        if (resource.equals("combinations")) {
            //rs.GetAll(resource);
            //setDataCombinations((Vector<combinations>) rs.Data());
            setDataCombinations((Vector<combinations>) cr.getVector());
        }

        if (resource.equals("product_features")) {
            //rs.GetAll(resource);
            //this.setDataProduct_Features((Vector<product_features>) rs.Data());
            this.setDataProduct_Features((Vector<product_features>) cr.getVector());
        }

        if (resource.equals("products")) {
            //rs.GetAll(resource);
            //this.setDataProducts((Vector<products>) rs.Data());
            this.setDataProducts((Vector<products>) cr.getVector());
        }
        if (resource.equals("configurations")) {
            //rs.GetAll(resource);
            //this.setDataConfigurations(rs.dataHas());
            this.setDataConfigurations(cr.getconfig());
        }

        if (resource.equals("taxes")) {
            //rs.GetAll(resource);
            //this.setDataConfigurations(rs.dataHas());
            this.setTaxes(cr.getconfig());
        }

        if (resource.equals("tax_rules")) {
            //rs.GetAll(resource);
            //this.setDataConfigurations(rs.dataHas());
            this.setTax_Rules(cr.getconfig());
        }
        if (resource.equals("tax_rule_groups")) {
            //rs.GetAll(resource);
            //this.setDataConfigurations(rs.dataHas());
            this.setTax_Rules_Groups(cr.getconfig());
        }

    }

    void setDataLanguages(Vector<languages> data) {
        this.data = data;
        this.ModelData = new Object[data.size()][data.get(0).getColumn()];
        this.MetaData = data.get(0).GetMetaData();
        for (int row = 0; data.size() > row; row++) {
            this.ModelData[row][0] = data.get(row).getId();
            this.ModelData[row][1] = data.get(row).getName();
            this.ModelData[row][2] = data.get(row).getIso_code();
            this.ModelData[row][3] = data.get(row).getLanguage_code();
            this.ModelData[row][4] = data.get(row).getDate_format_lite();
            this.ModelData[row][5] = data.get(row).getDate_format_full();
            this.ModelData[row][6] = data.get(row).getActive();
            this.ModelData[row][7] = data.get(row).getIs_rtl();
        }
    }

    void setDataManufacturers(Vector<manufacturers> data) {
        this.data = data;
        this.ModelData = new Object[data.size()][data.get(0).getColumn()];
        this.MetaData = data.get(0).GetMetaData();
        for (int row = 0; data.size() > row; row++) {
            this.ModelData[row][0] = data.get(row).getId();
            this.ModelData[row][1] = data.get(row).getActive();
            this.ModelData[row][2] = data.get(row).getName();
            this.ModelData[row][3] = data.get(row).getShort_description();
            this.ModelData[row][4] = data.get(row).getMeta_title();
            this.ModelData[row][5] = data.get(row).getMeta_description();
            this.ModelData[row][6] = data.get(row).getDescription();
            this.ModelData[row][7] = data.get(row).getMeta_keywords();
            this.ModelData[row][8] = data.get(row).getAddresses();
        }
    }

    void setDataSuppliers(Vector<suppliers> data) {
        this.data = data;
        this.ModelData = new Object[data.size()][data.get(0).getColumn()];
        this.MetaData = data.get(0).GetMetaData();
        for (int row = 0; data.size() > row; row++) {
            this.ModelData[row][0] = data.get(row).getId();
            this.ModelData[row][1] = data.get(row).getLink_rewrite();
            this.ModelData[row][2] = data.get(row).getName();
            this.ModelData[row][3] = data.get(row).getMeta_title();
            this.ModelData[row][4] = data.get(row).getMeta_description();
            this.ModelData[row][5] = data.get(row).getMeta_keywords();
            this.ModelData[row][6] = data.get(row).getDescription();
        }
    }

    void setDataCategories(Vector<categories> data) {
        this.data = data;
        this.ModelData = new Object[data.size()][data.get(0).getColumn()];
        this.MetaData = data.get(0).GetMetaData();
        for (int row = 0; data.size() > row; row++) {
            this.ModelData[row][0] = data.get(row).getId();
            this.ModelData[row][1] = data.get(row).getId_parent();
            this.ModelData[row][2] = data.get(row).getActive();
            this.ModelData[row][3] = data.get(row).getName();
            this.ModelData[row][4] = data.get(row).getLink_rewrite();
            this.ModelData[row][5] = data.get(row).getMeta_title();
            this.ModelData[row][6] = data.get(row).getMeta_description();
            this.ModelData[row][7] = data.get(row).getMeta_keywords();
            this.ModelData[row][8] = data.get(row).getDescription();
            this.ModelData[row][9] = data.get(row).getCategories();
            this.ModelData[row][10] = data.get(row).getProducts();
        }
    }

    void setDataCombinations(Vector<combinations> data) {
        this.data = data;
        this.ModelData = new Object[data.size()][data.get(0).getColumn()];
        this.MetaData = data.get(0).GetMetaData();
        for (int row = 0; data.size() > row; row++) {
            this.ModelData[row][0] = data.get(row).getId();
            this.ModelData[row][1] = data.get(row).getId_product();
            this.ModelData[row][2] = data.get(row).getReference();
            this.ModelData[row][3] = data.get(row).getSupplier_reference();
            this.ModelData[row][4] = data.get(row).getLocation();
            this.ModelData[row][5] = data.get(row).getEan13();
            this.ModelData[row][6] = data.get(row).getUpc();
            this.ModelData[row][7] = data.get(row).getWholesale_price();
            this.ModelData[row][8] = data.get(row).getPrice();
            this.ModelData[row][9] = data.get(row).getEcotax();
            this.ModelData[row][10] = data.get(row).getQuantity();
            this.ModelData[row][11] = data.get(row).getWeight();
            this.ModelData[row][12] = data.get(row).getDefault_on();
            this.ModelData[row][13] = data.get(row).getProduct_option_values();
            this.ModelData[row][14] = data.get(row).getImages();


        }
    }

    void setDataProduct_Features(Vector<product_features> data) {
        this.data = data;
        this.ModelData = new Object[data.size()][data.get(0).getColumn()];
        this.MetaData = data.get(0).GetMetaData();
        for (int row = 0; data.size() > row; row++) {
            this.ModelData[row][0] = data.get(row).getId();
            this.ModelData[row][1] = data.get(row).getName();

        }
    }

    void setDataProducts(Vector<products> data) {
        this.data = data;
        this.ModelData = new Object[data.size()][data.get(0).getColumn()];
        this.MetaData = data.get(0).GetMetaData();
        for (int row = 0; data.size() > row; row++) {
            this.ModelData[row][0] = data.get(row).getId();
            this.ModelData[row][1] = data.get(row).getId_manufacturer();
            this.ModelData[row][2] = data.get(row).getId_supplier();
            this.ModelData[row][3] = data.get(row).getId_category_default();
            this.ModelData[row][4] = data.get(row).getNewproduct();
            this.ModelData[row][5] = data.get(row).getCache_default_sttribute();
            this.ModelData[row][6] = data.get(row).getId_default_image();
            this.ModelData[row][7] = data.get(row).getId_default_combination();
            this.ModelData[row][8] = data.get(row).getId_tax_rules_group();
            this.ModelData[row][9] = data.get(row).getMinimal_quantity();
            this.ModelData[row][10] = data.get(row).getPrice();
            this.ModelData[row][11] = data.get(row).getAdditional_shipping_cost();
            this.ModelData[row][12] = data.get(row).getWholesale_price();
            this.ModelData[row][13] = data.get(row).isOn_sale();
            this.ModelData[row][14] = data.get(row).isOnline_only();
            this.ModelData[row][15] = data.get(row).getEcotax();
            this.ModelData[row][16] = data.get(row).getUnity();
            this.ModelData[row][17] = data.get(row).getUnit_price_ratio();
            this.ModelData[row][18] = data.get(row).getReference();
            this.ModelData[row][19] = data.get(row).getSupplier_reference();
            this.ModelData[row][20] = data.get(row).getLocation();
            this.ModelData[row][21] = data.get(row).getWidth();
            this.ModelData[row][22] = data.get(row).getHeigth();
            this.ModelData[row][23] = data.get(row).getDepth();
            this.ModelData[row][24] = data.get(row).getWeight();
            this.ModelData[row][25] = data.get(row).isQuantity_discount();
            this.ModelData[row][26] = data.get(row).getCustomizable();
            this.ModelData[row][27] = data.get(row).getUploadable_files();
            this.ModelData[row][28] = data.get(row).getText_fields();
            this.ModelData[row][29] = data.get(row).isActive();
            this.ModelData[row][30] = data.get(row).isAvailable_for_order();
            this.ModelData[row][31] = data.get(row).getAvailable_date();
            this.ModelData[row][32] = data.get(row).getCondition();
            this.ModelData[row][33] = data.get(row).isShow_price();
            this.ModelData[row][34] = data.get(row).getEan13();
            this.ModelData[row][35] = data.get(row).getUpc();
            this.ModelData[row][36] = data.get(row).isIndexed();
            this.ModelData[row][37] = data.get(row).getVisibility();
            this.ModelData[row][38] = data.get(row).isCache_is_pack();
            this.ModelData[row][39] = data.get(row).isIs_virtual();
            this.ModelData[row][40] = data.get(row).isCache_has_attachments();
            this.ModelData[row][41] = data.get(row).getDate_add();
            this.ModelData[row][42] = data.get(row).getDate_upd();
            this.ModelData[row][43] = data.get(row).isAdvanced_stock_management();
            this.ModelData[row][44] = data.get(row).getMeta_description();
            this.ModelData[row][45] = data.get(row).getMeta_keywords();
            this.ModelData[row][46] = data.get(row).getMeta_title();
            this.ModelData[row][47] = data.get(row).getLink_rewrite();
            this.ModelData[row][48] = data.get(row).getName();
            this.ModelData[row][49] = data.get(row).getDescription();
            this.ModelData[row][50] = data.get(row).getDescription_short();
            this.ModelData[row][51] = data.get(row).getAvailable_now();
            this.ModelData[row][52] = data.get(row).getAvailable_later();
            this.ModelData[row][53] = data.get(row).getCategories();
            this.ModelData[row][54] = data.get(row).getImages();
            this.ModelData[row][55] = data.get(row).getCombinations();
            this.ModelData[row][56] = data.get(row).getProduct_option_values();
            this.ModelData[row][57] = data.get(row).getProduct_features();
            this.ModelData[row][58] = data.get(row).getTags();

        }
    }

    void setDataConfigurations(Hashtable data) {
        this.dataHashtable = data;
    }

    public Hashtable getConfig() {
        return this.dataHashtable;

    }

    public Vector getData() {
        return data;
    }

    void setTaxes(Hashtable data) {
        this.dataHashtable = data;
    }

    public Hashtable getTaxes() {
        return this.dataHashtable;

    }

    void setTax_Rules(Hashtable data) {
        this.dataHashtable = data;
    }

    public Hashtable getTax_Rules() {
        return this.dataHashtable;

    }

        void setTax_Rules_Groups(Hashtable data) {
        this.dataHashtable = data;
    }

    public Hashtable getTax_Rule_Groups() {
        return this.dataHashtable;

    }
    public Object[][] getModelData() {
        return this.ModelData;
    }

    public String[] getMetaData() {
        return this.MetaData;
    }
}
